<?php
include_once("../c/config.php");
$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
$filename='t.txt';
if (!file_exists($filename)){
    $daAn=array();
    $sql="select * from ti ";
    $query=$mysqli->query($sql);
    while ($list=$query->fetch_assoc()){
        $daAn[$list['id']]=array('d'=>$list['dan'],'s'=>$list['step']);
    }
    file_put_contents($filename, json_encode($daAn));
}else{
    $daAn=json_decode(file_get_contents($filename),true);
}
$fenshu=0;
$sql="select * from c3_log where id=4  limit 0, 4";
$query=$mysqli->query($sql);
if($query->num_rows>0){
     $getc3=$query->fetch_assoc();
     
     
     $ida=json_decode($getc3['ida'],true);
     $udA=json_decode($getc3['d1'],true);
     foreach ($ida as $k=>$id){
         $getDan=$udA[$k];
         if (!empty($getDan) && $daAn[$id]['d'] == $getDan){
             $fenshu++;
         }
     }
     
     $idb=json_decode($getc3['idb'],true);
     $udB=json_decode($getc3['d2'],true);
     if (!empty($idb)){
         foreach ($idb as $k=>$id){
             $getDan=$udB[$k];
             if (!empty($getDan) && $daAn[$id]['d'] == $getDan){
                 $fenshu++;
             }
         }
     }
     
     
     echo "<br /><br />";
     $idc=json_decode($getc3['idc'],true);
     $udC=json_decode($getc3['d3'],true);
     if (!empty($idc)){
         foreach ($idc as $k=>$id){
             $getDan=explode(',', $udC[$k]);
             $getDanB=explode(',', $daAn[$id]['d']);
             $isequal=true;
             $getNum1=count($getDan);
             $getNum2=count($getDanB);
             if ($getNum1 != $getNum2){
                 $isequal=false;
             }
             if (true == $isequal){
                 foreach ($getDanB as $v){
                     $tmpZM=trim($v);
                     if (!in_array($tmpZM, $getDan))
                     {
                         $isequal=false;
                     }
                 }
             }
             if (true == $isequal){
                 $fenshu++;
                 echo '==:',$udC[$k];
                 echo "<br /><br />";
             }

         }
     }
     echo "<br /><br />";
     var_dump($idc);
     echo "<br /><br />";
     var_dump($udC);
     
     echo "<br /><br /><br /><br />";
     echo $fenshu;
     
     echo "<br /><br /><br /><br />";
     var_dump($getc3);
     
    
}

$mysqli->close();



?>